package com.qiangesoft.wechat.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiangesoft.wechat.entity.WxUser;
import com.qiangesoft.wechat.mapper.WxUserMapper;
import com.qiangesoft.wechat.service.IWxUserService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 微信用户 服务实现类
 * </p>
 *
 * @author qiangesoft
 * @since 2023-09-08
 */
@Service
public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser> implements IWxUserService {

    @Override
    public WxUser getByOpenId(String openId) {
        LambdaQueryWrapper<WxUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WxUser::getOpenId, openId)
                .last("limit 1");
        return baseMapper.selectOne(queryWrapper);
    }
}
